
const user = require('../models/userModel')
const mytoken = require('../../../libs/mytoken');
const { modules } = require('../../../conf');
const images = require('images')
const fs = require('fs')

let userController = {
    /**
     * 登录验证
     * @param {*} req 
     * @param {*} res 
     */
    post_login: function (req, res) {
        user.check_user(req, res)

    },

    /**
     * 更换头像
     * @param {*} req 
     * @param {*} res 
     */
    post_changheader: async function (req, res) {

        let pubUrl = './public/image/';

        fs.createReadStream(req.files.file.path).pipe(fs.createWriteStream(pubUrl + req.files.file.name))

        await user.change_header(req, res)


    },

    get_login: function (req, res) {
        res.send('login')
    },
    /**
     * 注册
     * @param {*} req 
     * @param {*} res 
     */
    post_logup: function (req, res) {

        user.user_logup(req, res)
    },
    /**
     * 发送验证码
     * @param {*} req 
     * @param {*} res 
     */
    post_sendtele: function (req, res) {
        console.log(1111);
        user.phone_verification(req, res)
    },

    /**
     * 忘记密码修改密码
     * @param {*} req 
     * @param {*} res 
     */
    post_restpaw: function (req, res) {
        console.log(2222);
        user.forget_password(req, res)
    }

}

module.exports = userController